require("../../utils/util.js");

var t = require("../../requests/request.js"), a = require("../../utils/common.js");

getApp();

Page({
    data: {
        hotbrand: {},
        masterlist: {},
        loading: !1,
        initails: [],
        winHeight: 0,
        currentTab: 0,
        isscroll: !0
    },
    onShareAppMessage: function() {
        return {
            title: "在线查询汽车报价、车型参数、汽车图片和汽车资讯",
            path: "/pages/index/index"
        };
    },
    onLoad: function() {
        var t = this;
        wx.getSystemInfo({
            success: function(a) {
                t.setData({
                    winHeight: a.windowHeight
                });
            }
        }), t.loadBrandData();
    },
    loadBrandData: function() {
        var a = this;
        a.setData({
            loading: !0
        }), t.getHotcarmaster(function(t) {
            for (var e = 0; e < 5; e++) t.Table[e].CoverPhoto = t.Table[e].CoverPhoto.replace("{0}", "3");
            a.setData({
                hotbrand: t.Table
            });
        }, null, function() {
            a.setData({
                loading: !1
            });
        }), t.getMasterList(function(t) {
            for (var e = [], n = 0; n < t.length - 1; n++) t[n].CoverPhoto = t[n].CoverPhoto.replace("{0}", "3"), 
            e.contains(t[n].Initial) || e.push(t[n].Initial);
            a.setData({
                initails: e.sort()
            }), a.setData({
                masterlist: t.sort(function(t, a) {
                    return a.UV - t.UV;
                })
            });
        });
    },
    onReady: function() {
        try {
            this.brand = this.selectComponent("#brand");
        } catch (t) {
            wx.redirectTo({
                url: "../oldindex/oldindex"
            });
        }
    },
    toDetailPage: function(t) {
        var a = t.currentTarget.dataset.id, e = t.currentTarget.dataset.name;
        try {
            this.brand.showDialog(a, e), this.setData({
                isscroll: !1
            });
        } catch (t) {}
    },
    hideModel: function() {
        this.brand.hideDialog(), this.setData({
            isscroll: !0
        });
    },
    onMyEvent: function(t) {
        wx.navigateTo({
            url: "../summary/summary?id=" + t.detail.id + "&name=" + t.detail.name
        });
    },
    toSearch: function() {
        wx.navigateTo({
            url: "../search/search"
        });
    },
    toNewCar: function() {
        wx.navigateTo({
            url: "../newcar/newcar"
        });
    },
    toEnergy: function() {
        wx.navigateTo({
            url: "../energycar/energycar"
        });
    },
    toSelectCar: function() {
        wx.navigateTo({
            url: "../xuanche/xuanche"
        });
    },
    scrollNum: function(t) {
        var a = t.currentTarget.dataset.num;
        this.setData({
            toNum: a
        });
    },
    errImg: function(t) {
        var e = this;
        a.errImgFun(t, e, "http://res.app.yiche.com/wechatapp/async100x100.png");
    }
}), Array.prototype.contains = function(t) {
    return RegExp(t).test(this);
};